<?php
/**
 * Created by PhpStorm.
 * User: wangwenfan
 * Date: 2018/8/2
 * Time: 21:54.
 */

namespace App\Admin\Controllers;

use App\Models\LoginLog\LogGiftCode;
use Encore\Admin\Facades\Admin;
use Encore\Admin\Grid;
use Encore\Admin\Layout\Content;

class GiftCodeLogController extends Controller
{
    /**
     * Index interface.
     *
     * @return Content
     */
    public function index()
    {
        return Admin::content(function (Content $content) {
            $content->header(trans('game.player_related'));
            $content->description(trans('game.code_claims_log'));
            $content->body($this->grid());
        });
    }

    protected function grid()
    {
        return Admin::grid(LogGiftCode::class, function (Grid $grid) {
            $grid->id();
            $grid->playerid(trans('game.role_id'));
            $grid->userid(trans('game.user_id'));
            $grid->name(trans('game.role_name'));
            $grid->code(trans('game.code'));
            $grid->time(trans('game.get_time'))->display(function ($time) {
                return date('Y-m-d H:i:s', $time);
            });
            $grid->disableCreateButton();
            $grid->disableActions();
            $grid->tools(function ($tools) {
                $tools->batch(function ($batch) {
                    $batch->disableDelete();
                });
            });
            $grid->filter(function ($filter) {
                $filter->disableIdFilter();
                $filter->like('code', trans('game.code'));
            });
        });
    }
}
